﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Settlement.Dto
@using FwProject.Core.SettlementInfoModel
@model IPagedList<SettlementReceivableDto>
@{
    Layout = null;
    decimal SumtotalPrice = 0;
    decimal SumDiscountprice = 0;
    decimal SumActualprice = 0;
    decimal SumUsePrePayment = 0;
    decimal SumUncollectedPrice = 0;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">
    <form class="form-horizontal" id="SettlementForm" asp-controller="Settlement" asp-action="DeleteSettlement" data-ajax="true" data-ajax-method="Post" data-ajax-success="ReloadAjaxCallbackgoback" data-ajax-failure="FailureAjaxCallback">
        <table id="t" class="table table-bordered table-hover table-rowselected">
            <thead>
                <tr>
                    <th style="text-align:center;width: 40px;">
                        <div class="i-checks" id="chkDiv">
                            <label class="ibox-tools" id="latd1">
                                <input type="checkbox" id="che" value="">
                            </label>
                        </div>
                    </th>
                    <th class="collapsed"></th>
                    <th style="width:45px">序号</th>
                    <th>状态</th>
                    <th>收款状态</th>
                    <th>开单时间</th>
                    <th>收据单号</th>
                    <th>餐厅名称</th>
                    <th>配送日期</th>
                    @*<th>收款司机</th>*@
                    <th>整单金额（￥）</th>
                    <th>优惠金额（￥）</th>
                    <th>使用预收款（￥）</th>
                    <th>应收金额（￥）</th>
                    <th>未收金额（￥）</th>
                    <th>优惠率（%）</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Count == 0)
                {
                    <tr><td class="text-center" colspan="14">暂无收据信息</td></tr>
                }
                else
                {
                    @foreach (var item in Model)
                    {
                        i++;
                        <tr data-value="@item.SettlementId">
                            <td style="text-align:center">
                                <div class="i-checks" data-value="@item.SettlementId">
                                    <input type="checkbox" name="che" value="@item.SettlementId"> <i></i>
                                </div>
                            </td>
                            <td class="collapsed"><i class="fa fa-plus-square-o" data-id="@item.SettlementId"></i></td>
                            <td>@i</td>
                            @if (item.ExamineStatus == ExamineStatus.未审核 || item.ExamineStatus == ExamineStatus.已退回)
                            {
                                <td style="color:red">@item.ExamineStatus</td>
                            }
                            else
                            {
                                <td style="color:forestgreen">@item.ExamineStatus</td>
                            }
                            <td>@item.RestaurantPayStatus</td>
                            <td>@item.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            <td><a href="javascript:top.window.openTab(1112,'收据[@item.CreationNumber]','/Receipt/SettlementDetails?id=@item.SettlementId')">@item.CreationNumber</a></td>
                            <td>@item.RestaurantName</td>
                            <td>@item.DeliveryDate</td>
                            @*<td>@item.DriverName</td>*@
                            <td>@item.TotalPrice</td>
                            <td>@(item.Discountprice + item.ReceivedDiscount)</td>
                            <td>@item.UsePrePayment</td>
                            <td>@item.Actualprice</td>
                            <td>@item.UncollectedPrice</td>
                            <td>@item.DiscountRate</td>
                        </tr>
                        <tr data-selectable="false" class="tb-child hidden">
                            <td colspan="6">
                                <div class="row m-b-lg">
                                    <div class="col-sm-12" style="width:100%">
                                        <div class="tabs-container">
                                            <div class="tabs-left">
                                                <div class="tab-content ">
                                                    <div class="tab-pane active">
                                                        <div class="panel-body" style="width:100%; margin-left:0;">
                                                            <table class="table table-bordered table-hover table-rowselected table-rowselected">
                                                                <thead class="disnot">
                                                                    <tr>
                                                                        <th>配送单号</th>
                                                                        <th>配送时间</th>
                                                                        <th>应收金额（￥）</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody class="tb_tbody"></tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        SumtotalPrice += item.TotalPrice;
                        SumDiscountprice += item.Discountprice;
                        SumActualprice += item.Actualprice;
                        SumUsePrePayment += item.UsePrePayment;
                        SumUncollectedPrice += item.UncollectedPrice;
                    }
                    <tr class="footer">
                        <td colspan="3" style="color:red;text-align:center">合计</td>
                        <td colspan="6"></td>
                        <td style="color:red">@SumtotalPrice</td>
                        <td style="color:red">@SumDiscountprice</td>
                        <td style="color:red">@SumUsePrePayment</td>
                        <td style="color:red">@SumActualprice</td>
                        <td style="color:red">@SumUncollectedPrice</td>
                        <td></td>
                    </tr>
                }

            </tbody>
        </table>
    </form>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&RestaurantName=@(Context.Request.Query["RestaurantName"])&DriverName=@(Context.Request.Query["DriverName"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model, page => Url.Action("Index", new { pageIdx = page, size = Context.Request.Query["size"], RestaurantName = Context.Request.Query["RestaurantName"], DriverName = Context.Request.Query["DriverName"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "LoadDataSuccessMessage", OnBegin = "AjaxBegin" }))
    </div>
</div>

